package qtdz9;

import javax.swing.*;

public class Battleship extends SeaObject {
    private int life;

    public Battleship() {
        super(66, 26, 270, 124, 20);
        life = 5;
    }

    public void move() {
        System.out.println("战舰x左右移动啦!");
    }

    public ImageIcon getImage() {
        return Images.battleship;
    }

    //发射炸弹,生成炸弹对象
    public Bomb shootBomb() {
        return new Bomb(this.getX(), this.getY());
    }

    //战舰左移
    public void moveLeft() {
        setX(getX() - getSpeed());
    }

    //战舰右移
    public void moveRight() {
        setX(getX() + getSpeed());
    }

    //战舰增命
    public void addLife(int num) {
        life += num;//命数增num
    }

    //获取命数
    public int getLife() {
        return life;
    }

    //减命
    public void subtractLife() {
        life--;
    }
}
